class DirBuilder
  # This class creates directories for the unit testing and 
  # destroys them when the testing is done. 
  
  # This class is currently only used in tests (& spikes.)
  
  def initialize arr
    @arr = arr
  end

  def build
    @arr.each do | item |
      path = item[0]
      content = item[1]

      if content.nil?
        Dir.mkdir(path)
      else
        File.open(path, 'w') { |file| file.puts content }
      end
    end
  end

  def raze
    @arr.reverse_each do | item |
      path = item[0]
      content = item[1]

      if content.nil?
        Dir.unlink(path)
      else
        File.unlink(path)
      end
    end
  end

  def DirBuilder.build arr
    DirBuilder.new(arr).build
  end
end
